import unittest

from requests import session

from api.login import Login


class TestLoginThree(unittest.TestCase):
    # 设置全局变量
    num = "123456"
    @classmethod
    def setUpClass(cls):
        cls.session = session()
        cls.login = Login()

    @classmethod
    def tearDownClass(cls):
        cls.session.close()

    # 第一次登录
    def test01_login_one(self):
        login_data = {"keywords": "18888888888", "password": "123456"}
        result = self.login.login(self.session, login_data)
        print(result.json())

    # 第二次登录
    def test02_login_two(self):
        login_data = {"keywords": "18888888888", "password": "123"}
        result = self.login.login(self.session, login_data)
        print(result.json())

    # 第三次登录
    @unittest.skip("跳过,密码有误")
    def test03_login_three(self):
        login_data = {"keywords": "18888888888", "password": "12"}
        result = self.login.login(self.session, login_data)
        print(result.json())

    # 第四次登录
    @unittest.skipIf(num == "123456", "跳过,密码有误")
    def test04_login_four(self):
        login_data = {"keywords": "18888888888", "password": "1"}
        result = self.login.login(self.session, login_data)
        print(result.json())

    # 第五次登录
    def test05_login_five(self):
        login_data = {"keywords": "18888888888", "password": "123456a"}
        result = self.login.login(self.session, login_data)
        print(result.json())